﻿CREATE FUNCTION [dbo].[fn_TimestampColumn]
(
	@Table sysname
)
RETURNS sysname
AS
BEGIN
	RETURN (
	    SELECT c.[name]
	    FROM   sys.tables t
	           INNER JOIN sys.[columns] c
	                ON  t.[object_id] = c.[object_id]
	           INNER JOIN sys.types ty
	                ON  c.system_type_id = ty.system_type_id
	    WHERE  t.[name] = @Table
     	       AND t.[type] = 'U'
	           AND ty.[name] IN ('TIMESTAMP', 'ROWVERSION')
	)
END